package com.library.common.wspoint.conf;

import com.library.common.utils.uuid.UUID;
import org.springframework.stereotype.Component;

import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import java.util.Map;

/**
 * @Package: com.library.framework.web.wspoint.conf
 * @ClassName: GlobalServerPointConfig
 * @Author: Yin
 * @Date: 14:36
 * @Description: 全局端点配置
 */
@Component
public class GlobalServerPointConfig extends ServerEndpointConfig.Configurator{

    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        Map<String, Object> properties = sec.getUserProperties();
        // 唯一标识
        String sessionKey = UUID.randomUUID().toString(true);
        properties.put("sessionKey",sessionKey);
    }
}
